<?php

declare(strict_types=1);

namespace Modules\Film\Models;

use Catch\Base\CatchModel as Model;
use Catch\Traits\DB\BaseOperate;
use Catch\Traits\DB\ScopeTrait;
use Catch\Traits\DB\Trans;
use Catch\Traits\DB\WithAttributes;
use Modules\Member\Models\Members;


class FilmOrder extends Model
{

    public $timestamps = true;
    protected $table = 'film_order';
    public $casts = [
        'ticket_code' => 'array',
        'ticket_img' => 'array',
    ];

    protected $fillable = [
        'id',
        'user_id',
        'ci',
        'ci_name',
        'cinema_id',
        'show_id',
        'buy_seats',
        'buy_num',
        'accept_changeseat',
        'mode',
        'phone_no',
        'order_sn',
        'status',
        'paid_at',
        'seats',
        'pic',
        'hall_name',
        'film_name',
        'show_info',
        'cinema_name',
        'show_name',
        'cinema_info',
        'original_price',
        'paid_price',
        'cost_price',
        'ticket_code',
        'ticket_img',
        'is_paid',
        'created_at',
        'updated_at',
        'deleted_at',
    ];

    public array $searchable = [
        'status' => '=',
    ];

    public function user()
    {
        return $this->belongsTo(Members::class, 'user_id', 'id');
    }
    public function getPaidAtAttribute($value)
    {
        if(!empty($value)){
            return date('Y-m-d H:i:s', $value);
        }

    }

}
